home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1992 August / info-mac-1992.iso / Applications (app) / Image 1.44 / Macros / Gel Plotting Macros < prev    next >
Text File  |  1992-02-26  |  4KB  |  166 lines

  1. var  {Global variables}
  2.   RoiLeft,RoiTop,RoiWidth,RoiHeight,PlotColor:integer;
  3.   GelWidth,GelHeight,MaxPlotWindowHeight:integer;
  4.   GelWindow,PlotWindow,PlotLeft,PlotTop,PlotWidth,PlotHeight:integer;
  5.   hMargin,vMargin,nLanes,SavePlotTop:integer;
  6.   LeftMargin,TopMargin,RightMargin,BottomMargin:integer;
  7.   FirstBackgroundPlot:boolean;
  8.  
  9. macro 'Setup to Plot Gel [Z]';
  10. {This macro, along with the Plot Lane macro, is used to generate profile}
  11. {plots of the lanes in a one dimensional electoproretic gel.}
  12. var
  13.   nPixels,mean,mode,min,max:real;
  14.   PlotWinHeight:integer;
  15. begin
  16.   PlotHeight:=175;
  17.   PlotWidth:=500;
  18.   MaxPlotWindowHeight:=720;
  19.   GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight);
  20.   if RoiWidth=0 then begin
  21.     PutMessage('The Setup macro expects the Gel to be displayed and the first lane outlined.');
  22.     exit;
  23.   end;
  24.   if PlotWidth<RoiWidth then PlotWidth:=RoiWidth;
  25.   if PlotWidth>(2*RoiWidth) then PlotWidth:=2*RoiWidth;
  26.   if RoiHeight>RoiWidth then begin
  27.     PutMessage('Lanes must be horizontal.');
  28.     exit;
  29.   end;
  30.   if nPics<>1 then begin
  31.     PutMessage('The window containing the gel should be the only image window open.');
  32.     exit;
  33.   end;
  34.   nLanes:=GetNumber('Number of lanes?',1);
  35.   GetPicSize(GelWidth,GelHeight);
  36.   MakeRoi(RoiLeft,RoiTop,RoiWidth,GelHeight-RoiTop);
  37.   Measure;
  38.   GetResults(nPixels,mean,mode,min,max);
  39.   hMargin:=5;
  40.   vMargin:=5;
  41.   if Calibrated
  42.   then LeftMargin:=35
  43.   else LeftMargin:=25;
  44.   TopMargin:=10;
  45.   RightMargin:=10;
  46.   BottomMargin:=20;
  47.   PlotLeft:=hMargin-LeftMargin;
  48.   PlotTop:=vMargin-TopMargin;
  49.   SavePlotTop:=PlotTop;
  50.   PlotWinHeight:=nLanes*PlotHeight+2*vMargin;
  51.   if PlotWinHeight>MaxPlotWindowHeight then begin
  52.     PlotWinHeight:=MaxPlotWindowHeight;
  53.     PlotHeight:=(PlotWinHeight-2*vMargin)/nLanes;
  54.   end;
  55.   SetNewSize(PlotWidth+2*hMargin,PlotWinHeight);
  56.   SetForegroundColor(255);
  57.   SetBackgroundColor(0);
  58.   MakeNewWindow('Plots');
  59.   SetPlotSize(PlotWidth,PlotHeight);
  60.   min:=min-1;
  61.   if min<0 then min:=0;
  62.   max:=max+5;
  63.   if max>255 then max:=255;
  64.   SetPlotScale(cValue(min),cValue(max));
  65.   SetPlotLabels(false);
  66.   GelWindow:=1;
  67.   PlotWindow:=2;
  68.   SelectPic(GelWindow);
  69.   MakeRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight);
  70.   FirstBackgroundPlot:=true;
  71.   PlotColor:=1;
  72.   ResetCounter;
  73.   MeasureArea(true);
  74.   MeasureDensity(false);
  75.   WandAutoMeasure(true);
  76.   AdjustAreas(true);
  77.   LabelParticles(false);
  78.   IncludeInteriorHoles(true);
  79.   SetFontSize(9);
  80.   SetText('Centered');
  81.   SetLineWidth(1);
  82. end;
  83.  
  84.  
  85. macro 'Plot Lane [P]';
  86. var
  87.   left,top,width,height:integer;
  88. begin
  89.   if (GelWidth=0) or (nPics=1) then begin
  90.     PutMessage
  91.       ('Before using the Plot Lane macro you must first use the Setup macro.');
  92.     Exit;
  93.   end;
  94.   GetRoi(left,top,width,height);
  95.   MakeRoi(RoiLeft,top,RoiWidth,RoiHeight);
  96.   SetOption;
  97.   ColumnAveragePlot;
  98.   Copy;
  99.   SelectPic(PlotWindow);
  100.   MakeRoi(PlotLeft,PlotTop,PlotWidth+LeftMargin+RightMargin,
  101.           PlotHeight+TopMargin+BottomMargin);
  102.   Paste;
  103.   DoOr;
  104.   PlotTop:=PlotTop+PlotHeight-1;
  105.   SelectPic(GelWindow);
  106. end;
  107.  
  108.  
  109. macro 'Plot Background Lane [B]';
  110. {Plot all lanes before plotting backgrounds. Unlike the lane plotting macro,}
  111. {you are allowed to change the height of the selection.}
  112. var
  113.   left,top,width,height:integer;
  114. begin
  115.   if (GelWidth=0) or (nPics=1) then begin
  116.     PutMessage('Use Setup first.');
  117.     Exit;
  118.   end;
  119.   GetRoi(left,top,width,height);
  120.   MakeRoi(RoiLeft,top,RoiWidth,height);
  121.   ColumnAveragePlot;
  122.   Copy;
  123.   SelectPic(PlotWindow);
  124.   if FirstBackgroundPlot then begin
  125.     FirstBackgroundPlot:=false;
  126.     PlotTop:=SavePlotTop;
  127.   end;
  128.   MakeRoi(PlotLeft,PlotTop,PlotWidth+LeftMargin+RightMargin,
  129.           PlotHeight+TopMargin+BottomMargin);
  130.   Paste;
  131.   DoOr;
  132.   PlotTop:=PlotTop+PlotHeight-1);
  133.   SelectPic(GelWindow);
  134. end;
  135.  
  136.  
  137. macro 'Plot Overlayed [O]';
  138. var
  139.   left,top,width,height:integer;
  140. begin
  141.   if (GelWidth=0) or (nPics=1) then begin
  142.     PutMessage('Use Setup first.');
  143.     Exit;
  144.   end;
  145.   if PlotColor=1 then SetPalette('256 Color Spectrum');
  146.   GetRoi(left,top,width,height);
  147.   MakeRoi(RoiLeft,top,RoiWidth,height);
  148.   ColumnAveragePlot;
  149.   Copy;
  150.   SelectPic(PlotWindow);
  151.   if PlotColor=1 then SetPalette('256 Color Spectrum');
  152.   SetForegroundColor(PlotColor);
  153.   PlotTop:=PlotTop-PlotHeight+1);
  154.   if PlotTop<SavePlotTop then PlotTop:=SavePlotTop;
  155.   MakeRoi(PlotLeft,PlotTop,PlotWidth+LeftMargin+RightMargin,
  156.           PlotHeight+TopMargin+BottomMargin);
  157.   Paste;
  158.   DoOr;
  159.   PlotTop:=PlotTop+PlotHeight-1);
  160.   SelectPic(GelWindow);
  161.   PlotColor:=(PlotColor+74) mod 254;
  162. end;
  163.  
  164.  
  165.  
  166.